/*
 * @Author: Jimmy
 * @LastModifiedBy: Jimmy
 * @Date: 2024-07-06 20:57:49
 * @LastEditTime: 2024-09-07 20:44:19
 * @FilePath: /nest_study/server/src/modules/monitor/login-log/login-log.controller.ts
 */
import { Controller, Get, Post, Body, Delete, Query, Res } from '@nestjs/common';
import { LoginLogService } from './login-log.service';
import { ApiBody, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ListLoginlogDto } from './dto/index.dto';
import { Response } from 'express'

@ApiTags('登录日志')
@Controller('monitor/login_log')
export class LoginLogController {
  constructor(private readonly loginLogService: LoginLogService) { }

  @ApiOperation({
    summary: '登录日志-列表',
  })
  @ApiBody({
    type: ListLoginlogDto,
    required: true,
  })
  @Get('/list')
  findAll(@Query() query: ListLoginlogDto) {
    return this.loginLogService.findAll(query);
  }

  @ApiOperation({
    summary: '登录日志-清除全部日志',
  })
  @Delete('/clean')
  removeAll() {
    return this.loginLogService.removeAll();
  }

  @ApiOperation({
    summary: '登录日志-删除日志',
  })
  @Delete('/delete')
  remove(@Body() info: { ids: number[] }) {
    return this.loginLogService.remove(info.ids);
  }

  @ApiOperation({ summary: '导出登录日志为xlsx文件' })
  @Post('/export')
  export(@Res() res: Response, @Body() body: any) {
    return this.loginLogService.export(res, body);
  }
}
